package model.ability;

import model.map.MapPoint;
import model.map.MapPointTreeNode;

/**
 * Placement algorithm which creates a straight line of points
 * in the direction of the caster.
 * @author Zachary
 */
public class Line extends PlacementAlgorithm {
	@Override
	public MapPointTreeNode calculateDisplacementSet(MapPoint direction, int range) {
		if(!MapPoint.isValidDirection(direction))
			return null;
		
		MapPointTreeNode head = new MapPointTreeNode(ORIGIN);
		
		MapPointTreeNode curr = head;
		MapPointTreeNode next = null;
		
		for(int i = 1;i<=range;i++){
			next = new MapPointTreeNode(MapPoint.addPoints(curr.getMapPoint(), direction));
			curr.addChild(next);
			curr = next;
		}
		
		return head;
	}
}
